<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Update Notice Board</title>
<SCRIPT type="text/javascript">

$(document).ready(function(){

		// variable to hold notice board's initial content.
		var nbText;
		
  		$("#clearTxtAreaBtn").click(function(){
	   		// alert($("#noticeBoardText").val());
		  	var data = $("#noticeBoardText").val("").focus();
	  	});

	  	$("#newLineBtn").click(function(){
		   // alert($("#noticeBoardText").val());
			  var data = $("#noticeBoardText").val();
			  $("#noticeBoardText").val(data + "<br/>\n").focus();
			  // $("#noticeBoardText").focus();  
		});

	  	$("#noticeBoardText").change(function(){
			// alert("changed : " + $("#successMsg").length);
			if($("#successMsg").length)
			{
				// alert("true");
				$("#successMsg").html("Click Update button to Save changes").removeClass("success").addClass('error');
			}
			else
			{
				$("#msgsDiv").html('<div id="successMsg" class="error">Click Update button to Save changes.</div>');
			}
		});
		
	});


</SCRIPT>

</head>
<body>
<table class="updateNoticeBoardPage" border="0">
	<tr>
		<td>
		<h4>Update Notice Board</h4>
		</td>
	</tr>
	<tr>
		<td>You can update Notice Board and Thought of the day seen on
		the home page.</td>
	</tr>
	<tr>
		<td><form:form action="updateNoticeBoard"
			commandName="noticeBoard" method="POST">
			<div id="msgsDiv" style="width: 100%">
			<s:bind path="*">
				<c:if test="${success}">
					<div id="successMsg" class="success">Notice Board Updated.</div>
				</c:if>
			</s:bind>
			</div>
			<fieldset><legend>Update Notice Board</legend>
			<table class="form-table" border="0">
				<tr>
					<td colspan="3"><c:if test="${status.error}">
						<div id="message" class="error">Form has errors</div>
					</c:if></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input id="newLineBtn" type="button" class="button-small"
						value="New Line" /> &nbsp;&nbsp;&nbsp; <input
						id="clearTxtAreaBtn" type="button" class="button-small"
						value="Clear" /></td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td width="80"><form:label path="noticeBoardText">Notice Board Text</form:label></td>
					<td><form:textarea path="noticeBoardText" id="noticeBoardText"
						rows="15" cols="50" /></td>
					<td colspan="2" class="error" width="250">&nbsp;<form:errors
						path="noticeBoardText" cssStyle="color:red;" /></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="submit" value="update" class="button" /></td>
					<td>&nbsp;</td>
				</tr>
			</table>
			</fieldset>
		</form:form></td>
	</tr>
</table>
</body>
</html>